﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using System.Web.Routing;
using MyNeighbourhood.RouteConstraints;

namespace MyNeighbourhood
{
    public class RouteConfig
    {
        public static void RegisterRoutes(RouteCollection routes)
        {
            routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
            
            routes.MapRoute(
            name: "apartment",
            url: "apartment/{ad_type}/{apartment_type}/{address}",
            defaults: new { controller = "Ad", action = "ApartmentDetails" },
            constraints: new { ad_type = new AdTypeConstraint(), apartment_type = new ApartmentTypeConstraint() }
            );

            routes.MapRoute(
            name: "car",
            url: "car/{maker}/{model}/{year}",
            defaults: new { controller = "Ad", action = "CarDetails" },
            constraints: new { year = new YearConstraint() }
            );

            routes.MapRoute(
            name: "furniture",
            url: "furniture/{type}/{material}",
            defaults: new { controller = "Ad", action = "FurnitureDetails" },
            constraints: new { type = new FurnitureTypeConstraint(), material = new MaterialConstraint() }
            );

            routes.MapRoute(
                name: "Default",
                url: "{controller}/{action}/{id}",
                defaults: new { controller = "Home", action = "Splash", id = UrlParameter.Optional }
            );
        }
    }
}